<?php
class ForumImages extends CActiveRecord {

    public $imgId;
    public $typeId;
    public $type;
    public $bigImg;
    public $smallImg;
    
    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public function tableName() {
        return 'forum_images';
    }
    
    protected function afterDelete() {
        if(file_exists(Yii::getPathOfAlias('webroot').'/images/uploads/comments/'.$this->bigImg)) 
            unlink(Yii::getPathOfAlias('webroot').'/images/uploads/comments/'.$this->bigImg);
        if(file_exists(Yii::getPathOfAlias('webroot').'/images/uploads/comments/'.$this->smallImg)) 
            unlink(Yii::getPathOfAlias('webroot').'/images/uploads/comments/'.$this->smallImg);
    }
}